import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        notes: [],
        timestamps: [],
    },
    mutations: {
        addNote (state, payload) {
            const newNote: any = payload;
            console.log(newNote);
            (state.notes as any).push(newNote)
        },
        addTimestamp (state, payload) {
            const newTimestamp = payload;
            console.log(newTimestamp);
            (state.timestamps as any).push(newTimestamp)
        }
    },
    actions: {
        addNote (state, payload) {
            const newNote: any = payload;
            console.log(newNote);
            this.commit("addNote",newNote);
        },
        addTimestamp (state, payload) {
            const newTimestamp = payload;
            console.log(newTimestamp);

        }
    },
    modules: {},
    getters: {
        getNotes:state => state.notes,
        getTimestamps:state => state.timestamps,
        getNoteCount:state => state.notes.length
    }
})
